package pro.softzhang.algo.lc1200;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 *
 */
public class LC1268_SearchSuggestionsSystem {
    public static void main(String[] args) {

    }

    /**
     *
     */
    static
    class Solution {
        public List<List<String>> suggestedProducts(String[] products, String searchWord) {
            Arrays.sort(products);
            List<List<String>> suggested = new ArrayList<>();
            for(int i = 1; i <= searchWord.length(); i++) {
                List<String> l = new ArrayList<>();
                String prefix = searchWord.substring(0, i);
                for(String product : products) {
                    if (product.startsWith(prefix)) {
                        l.add(product);
                    }
                    if (l.size() == 3) break;
                }
                suggested.add(l);
            }
            return suggested;
        }
    }

    /**
     *
     */
    static
    class Solution1 {
        public List<List<String>> suggestedProducts(String[] products, String searchWord) {
            return null;
        }
    }
}
